import _ from "lodash";
import ConstRobotConfig from "./ConstRobotConfig";
import { RobotEntity } from "./RobotEntity";

export class RobotManager {

    private static _instance: RobotManager;

    public static get inst(): RobotManager {
        if (!this._instance) {
            this._instance = new RobotManager();
        }
        return this._instance;
    }

    private _robots: RobotEntity[] = [];



    public init(): void {

        _.each(ConstRobotConfig, config => {
            const robot: RobotEntity = new RobotEntity();
            robot.username = config.username;
            robot.password = config.password;
            
            robot.start();
            this._robots.push(robot);
        });
    }
    


    public update(dt: number) {
        
        _.each(this._robots,bot=>{
            bot.tick();
        });
    }
}